﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] != null)
        {
            Response.Redirect("Home.aspx");
            }

        Label3.Visible = false;
    }
    protected void txtUsername_TextChanged(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ManagementUser dt = new ManagementUser();
        ORANGE_PROJECTModel.Manager m = (ORANGE_PROJECTModel.Manager)dt.checkLogin(txtUsername.Text, txtPassword.Text);

        if (m.ManagerID != null)
        {
            Session["username"] = m.ManagerID;
            Session["fullname"] = m.Name;
            Response.Redirect("Home.aspx");
        }
        else {
            Label3.Visible = true;
        }
    }
}